angular - 贝宝结帐 | 403 禁止错误
问题描述
我的问题是每次单击页面上的贝宝按钮时,它都会短暂弹出,然后给出 403 禁止错误。这个问题与我的问题最接近为什么我一直收到 PayPal 禁止的 403?但不同,因为我使用的是角度。
这是我的角度代码的相关部分:
import { Component, OnInit, AfterViewChecked } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import { ShoppingCartService} from '../shopping-cart.service';
import { PaymentsService } from '../payments.service';
import { environment } from '../../environments/environment';
import { StripeToken } from 'stripe-angular';
declare let paypal: any;
@Component({
selector: 'app-cartpage',
templateUrl: './cartpage.component.html',
styleUrls: ['./cartpage.component.css']
})
export class CartpageComponent implements OnInit, AfterViewChecked {
cartItems;
id = localStorage.getItem('cartId');
storage: any = [];
addToCart = [];
parents: any = [];
total = 0;
number: any = 0;
handler: any;
amount: 500;
addScript: boolean = false;
finalAmount: number = this.total;
paypalConfig = {
env: 'sandbox',
client: {
sandbox: 'my-key',
production: 'my-key'
},
commit: true,
payment : (data, actions) => {
return actions.payment.create({
payment: {
transactions: [
{ amount: {total: this.finalAmount, currency: 'USD' } }
]
}
})
},
onAuthorize: (data, actions) => {
return actions.payment.execute().then((payment)=>{
//do something when payment is successful
})
}
};
ngAfterViewChecked() : void {
if(!this.addScript) {
this.addPaypalScript().then(() => {
paypal.Button.render(this.paypalConfig, '#paypal-checkout-button')
})
}
}
addPaypalScript() {
this.addScript = true;
return new Promise((resolve, reject) => {
let scriptTagElement = document.createElement('script');
scriptTagElement.src = "https://www.paypalobjects.com/api/checkout.js";
scriptTagElement.onload = resolve;
document.body.appendChild(scriptTagElement);
})
}
这是我在控制台中的错误:
POST https://www.sandbox.paypal.com/v1/payments/payment 403(禁止)
未捕获的错误:错误:发布https://www.sandbox.paypal.com/v1/payments/payment的请求 失败,出现 403 错误。相关 ID:3ef24e19eb852、3ef24e19eb852
{
"name": "PERMISSION_DENIED",
"message": "No permission for the requested operation",
"information_link": https://developer.paypal.com/docs/api/payments/#errors",
"debug_id": "3ef24e19eb852"
}
任何帮助或有用的帖子/文章将不胜感激,谢谢
更新 5/05/2018 Paypal 仍未解决此问题。但是,如果您想检查是否已正确设置所有内容,则可以使用 paypal 的沙箱凭据对其进行测试。https://developer.paypal.com/demo/checkout/#/pattern/client
解决方案
推荐阅读
- excel - 初始化时在 Excel 用户表单内的 Google 地图上搜索城市
- java - 程序在可执行 jar 中的“new MimeMessage(session)”上退出
- javascript - 删除每个用户对象上的键值对
- javascript - 在 webpack 加载器中获取入口点名称
- sql - 窗口分析函数,其中窗口框架和顺序是不同的字段?
- javascript - 映射数组中的所有对象
- neo4j - 针对特定情况修改的度中心性
- java - lambda中的无限while循环内的Thread.sleep不需要'catch(InterruptedException)' - 为什么不呢?
- android - 如何解决“令牌检索失败:AUTHENTICATION_FAILED”?
- reactjs - ReactJS:如何使用 Formik 处理图像/文件上传?